// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr, Xeno - domination
// Edited by:  Neumatic
// Warcontext: Create a settings dialog box
// -----------------------------------------------

private ["_text","_viewdist","_terraingrid","_viewdistmax"];

menuaction = -1;

playSound "paper";

_terraingrid = wcterraingrid;
_viewdist = wcviewdist;
_viewdistmax = wcviewdistance;

ctrlSetText [13001, format [localize "STR_ACGUI_VM_TXT_VD", _viewdist]];
ctrlSetText [13003, format [localize "STR_ACGUI_VM_TXT_TG", (50 - _terraingrid)]];

sliderSetRange [13002,100, _viewdistmax];
sliderSetRange [13004,0, 50];

sliderSetPosition [13002, _viewdist];
sliderSetPosition [13004, (50 - _terraingrid)];

_text = "Game settings";
lbAdd [13007, _text];

for "_i" from 0 to (count paramsArray - 1) do {
	_text = format ["%1 = %2", configName ((missionConfigFile >> "Params") select _i), paramsArray select _i];
	lbAdd [13007, _text];
};

_text = "";
lbAdd [13007, _text];

_text = "Missing Addons";
lbAdd [13007, _text];

if (count wccfglocalpatches > 0) then {
	{
		_text = format ["%1", _x];
		lbAdd [13007, _text];
	} foreach wccfglocalpatches;
} else {
	_text = "None";
	lbAdd [13007, _text];
};

while {alive player && {dialog}} do {
	_viewdist = floor (sliderPosition 13002);
	_terraingrid = (50 - floor (sliderPosition 13004));

	ctrlSetText [13001, format [localize "STR_ACGUI_VM_TXT_VD", _viewdist]];
	ctrlSetText [13003, format [localize "STR_ACGUI_VM_TXT_TG", (50 - _terraingrid)]];

	if (menuaction == 2) then {
		menuaction = -1;
		closeDialog 0;

		setViewDistance _viewdist;
		setTerrainGrid _terraingrid;

		wcterraingrid = _terraingrid;
		wcviewdist = _viewdist;
	};

	sleep 0.1;
};